package org.example.controller.admin;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.entity.Dianpu;
import org.example.entity.Product;
import org.example.entity.Shanpin;
import org.example.result.PageResult;
import org.example.result.Pages;
import org.example.result.Result;
import org.example.service.DianpuService;
import org.example.service.ShanpinService;
import org.example.vo.ProductVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/admin/shanpin")
@Slf4j
@Api(tags = "商品相关接口")
public class EmployeeshanpinController {

    @Autowired
    ShanpinService shanpinService;

    @Autowired
    DianpuService dianpuService;
    /**
     * 主页商品查询
     * @param
     * @return
     */
    @GetMapping ("/shanpincx")
    @ApiOperation(value = "主页商品查询")
    public Result<List<Shanpin>> zhuyeshanpincx() {
        log.info("商品查询：{}");
        return Result.success( shanpinService.zhuyeshanpincx());
    }

    /**
     * 主页商品搜索查询
     * @param
     * @return
     */
    @GetMapping ("/shanpinsousocx")
    @ApiOperation(value = "主页商品搜索查询")
    public Result<List<Shanpin>> zhuyeshanpinsousocx(@RequestParam( "souso") String souso) {
        log.info("商品搜索查询：{}");
        return Result.success( shanpinService.zhuyeshanpinsousocx(souso));
    }


    /**
     * 商品查询
     * @param
     * @return
     */
    @GetMapping ("/shanpindancx")
    @ApiOperation(value = "单个商品查询")
    public Result<ProductVO> shanpindancx(@RequestParam( "id") int id) {
        log.info("商品查询：{}", id);
        return Result.success( shanpinService.xgcx(id));
    }


    /**
     * 商品照片查询
     * @param
     * @return
     */
    @GetMapping ("/shanpinzhaopian")
    @ApiOperation(value = "单个商品照片查询")
    public Result<String[]> shanpinzhaopian(@RequestParam( "id") int id) {
        log.info("商品照片查询：{}", id);
        return Result.success( shanpinService.zhaopiancx(id));
    }


    /**
     * 商品店铺查询
     * @param
     * @return
     */
    @GetMapping ("/shanpindianpu")
    @ApiOperation(value = "单个商品店铺查询")
    public Result<Dianpu> shanpindianpu(@RequestParam( "username") String username) {
        log.info("商品店铺查询：{}", username);
        return Result.success( dianpuService.dianpucx(username));
    }


    /**
     * 店铺商品查询
     * @param
     * @return
     */
    @GetMapping ("/shanpindianpucx")
    @ApiOperation(value = "店铺商品查询")
    public Result<List<Shanpin>> shanpindianpucx(@RequestParam( "id") int id) {
        log.info("店铺商品查询：{}");
        return Result.success( shanpinService.shanpindianpucx(id));
    }

    /**
     * 相关商品查询
     * @param
     * @return
     */
    @GetMapping ("/shanpinfelecx")
    @ApiOperation(value = "相关商品查询")
    public Result<List<Shanpin>> shanpinxgcx(@RequestParam( "id") int id) {
        log.info("相关商品查询：{}");
        return Result.success( shanpinService.shanpinxgcx(id));
    }

}
